import { useState } from "react";
import { Button } from "antd";
function UserInfo(props) {
  let [created, setCreated] = useState(props.user.created);
  async function changeFormat() {
    let moment = await import("moment");
    setCreated(moment.default(props.user.created).fromNow());
  }
  return (
    <>
      <p>用户名:{props.user.username}</p>
      <p>密码:{props.user.password}</p>
      <p>
        创建时间:{created}
        <Button onClick={changeFormat}>切换为相对时间</Button>
      </p>
    </>
  );
}
export default UserInfo;
